import Vue from 'vue'
import echarts from 'echarts'
import 'echarts/lib/chart/bar'
import App from './App.vue'
import router from './router'
import store from './store'
import './registerServiceWorker'
import './css/base.css'
import VueCookies from 'vue-cookies'

Vue.prototype.$echarts = echarts

Vue.config.productionTip = false
Vue.use(VueCookies)

var vm = new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

const swipeRoute = ['Board', 'Sign', 'Receive', 'Index']
var container = document.getElementById('top')
var mc = new window.Hammer.Manager(container)
var swipe = new window.Hammer.Swipe()
mc.add(swipe)
mc.on('swipeleft', (e) => {
  var leftactive = vm.$route.meta.active
  if (leftactive === 3) {
    leftactive = -1
  }

  vm.$router.push({ name: swipeRoute[leftactive + 1] })
  console.log('swipeleft')
})
mc.on('swiperight', (e) => {
  var rightactive = vm.$route.meta.active
  if (rightactive === 0) {
    rightactive = 4
  }
  vm.$router.push({ name: swipeRoute[rightactive - 1] })
  console.log('swiperight')
})
